capture log close
log using conjointanalysis, replace text
//program:  conjointanalysis.do
//task:    Replication code for MTurk conjoint analyses   
//project:  Ideology, Information, and Social Welfare Preferences (American Politics Research)  
//authors: Hang Qi & Jake Haselswerdt
//updated 9/25/23

//program setup
version 18
clear all
set linesize 90
macro drop _all
set scheme s1mono
set more off
set level 90 

use conjoint_all.dta, clear

//estimate AMCEs with ideological subgroups
**forced choice
*all respondents
ssc install conjoint /*Install conjoint command*/
conjoint program_choice cat_a_desc cat_a_prob1 cat_a_prob2 cat_a_funding cat_a_cost cat_a_number cat_a_time, est(amce) id(id) constraint(cat_a_desc#cat_a_prob1#cat_a_prob2) subgroup(ideo3) 
matrix liberal_choice = e(results_Liberal)
matrix moderate_choice = e(results_Moderate)
matrix conservative_choice = e(results_Conservative)

*generate figure 2.
display _asis "`e(graph_code)'"

global labelreplace EITC_basic_description = "EITC basic" EITC_working_description = "EITC working" TANF_basic_description = "TANF basic" TANF_self_sufficient_description = "TANF self-sufficient" EITC_inadequacy_tax_time = "EITC inadequacy tax time" EITC_inadequacy_unemployment___e = "EITC inadequacy unemployment" TANF_inadequacy_most_don_t_quali = "TANF inadequacy most don't qualify" TANF_inadequacy_benefits_too_sma = "TANF inadequacy benefits too small" EITC_fraud_larger_credit = "EITC fraud larger credit" EITC_fraud_paid_preparers = "EITC fraud paid preparers" TANF_fraud_easy_to_lie = "TANF fraud easy to lie" TANF_fraud_improper_payments = "TANF fraud improper payments" Federal_and_state = "Federal & state" _19_billion = "$19 billion" _27_billion="$27 billion" _53_billion="$53 billion" _70_billion="$70 billion" _5_million_people = "5 million" _8_million_people = "8 million" _17_million_people = "17 million" _25_million_people = "25 million" No_time_limit = "No time limit" _2_years = "2 years" _4_years = "4 years" _8_years = "8 years"

coefplot  matrix(liberal_choice[,1]), bylabel(Liberal) || ///
matrix(conservative_choice[,1]), bylabel(Conservative) ||, ci(( 5 6)) ///
keep(*:) xline(0, lpattern(-) lcolor(black)) xlabel(-.1(.1).1) xtick(-.15(.05).15) coeflabels($labelreplace, labsize(vsmall)) eqlabels( "{bf:Policy Description}" "{bf:Policy Problem 1}" "{bf:Policy Problem 2}" "{bf:Funding Provided by}" "{bf:Total Cost per Year}" "{bf:Participant Population}" "{bf:Time Limit}", asheadings) byopts(graphregion(col(white)) cols(3)) subtitle(, fcolor (gs15)) scale(0.7) xtitle({bf:Estimated AMCEs (forced choice)}) 
gr export Figures/choice_ideo2_amce.png, as(png) replace

//formal hypothesis tests
**H1(M) (H1a(P)) Information about inadequate benefits will have a larger negative impact on liberals' support than on conservatives' support.
*forced choice (dropping least attentive respondents)
reg program_choice i.cat_a_prob1##i.libcon if screener_2plus==1, cl(id)
testparm i.cat_a_prob1#i.libcon
di r(p) /*to show more digits*/

*forced choice (all respondents)
reg program_choice i.cat_a_prob1##i.libcon, cl(id)
testparm i.cat_a_prob1#i.libcon
di r(p) /*to show more digits*/

*program support (dropping least attentive respondents)
reg program_support i.cat_a_prob1##i.libcon if screener_2plus==1, cl(id)
testparm i.cat_a_prob1#i.libcon
di r(p) /*to show more digits*/

*program support (all respondents)
reg program_support i.cat_a_prob1##i.libcon, cl(id)
testparm i.cat_a_prob1#i.libcon
di r(p) /*to show more digits*/

**H2(M) (H1b(P)) Information about inefficiencies and fraud will have a larger negative impact on conservatives' support than on liberals' support.
*forced choice (dropping least attentive respondents)
reg program_choice i.cat_a_prob2##i.libcon if screener_2plus==1, cl(id)
testparm i.cat_a_prob2#i.libcon

*forced choice (all respondents)
reg program_choice i.cat_a_prob2##i.libcon, cl(id)
testparm i.cat_a_prob2#i.libcon

*program support (dropping least attentive respondents)
reg program_support i.cat_a_prob2##i.libcon if screener_2plus==1, cl(id)
testparm i.cat_a_prob2#i.libcon

*program support (all respondents)
reg program_support i.cat_a_prob2##i.libcon, cl(id)
testparm i.cat_a_prob2#i.libcon 
di r(p)

**H2(P) Negative policy information will have a larger effect in general for submerged state programs than for traditional welfare programs.
*forced choice (dropping least attentive respondents)
reg program_choice eitc_problem tanf_problem eitc_tanf if screener_2plus==1, cl(id)
lincom eitc_problem-tanf_problem

*forced choice (all respondents)
reg program_choice eitc_problem tanf_problem eitc_tanf, cl(id)
lincom eitc_problem-tanf_problem

*program support (dropping least attentive respondents)
reg program_support eitc_problem tanf_problem eitc_tanf if screener_2plus==1, cl(id)
lincom eitc_problem-tanf_problem

*program support (all respondents)
reg program_support eitc_problem tanf_problem eitc_tanf, cl(id)
lincom eitc_problem-tanf_problem

**H3(M&P) Describing a program as being funded by state (as opposed to federal) government will have a larger positive impact on conservatives' support than on liberals' support.
*forced choice (dropping least attentive respondents)
reg program_choice 2.cat_a_funding##i.libcon if screener_2plus==1, cl(id)

*forced choice (all respondents)
reg program_choice 2.cat_a_funding##i.libcon, cl(id)

*program support (dropping least attentive respondents)
reg program_support 2.cat_a_funding##i.libcon if screener_2plus==1, cl(id)

*program support (all respondents)
reg program_support 2.cat_a_funding##i.libcon, cl(id) 

**H4(M&P) Describing a program as having a time limit for receiving benefits (especially a shorter time limit) will have a larger positive impact on conservatives' support than on liberals' support.
*forced choice (dropping least attentive respondents)
reg program_choice i.cat_a_time##i.libcon if screener_2plus==1, cl(id)
testparm i.cat_a_time#i.libcon
di r(p) /*to show more digits*/

*forced choice (all respondents)
reg program_choice i.cat_a_time##i.libcon, cl(id)
testparm i.cat_a_time#i.libcon
di r(p) /*to show more digits*/

*program support (dropping least attentive respondents)
reg program_support i.cat_a_time##i.libcon if screener_2plus==1, cl(id)
testparm i.cat_a_time#i.libcon

*program support (all respondents)
reg program_support i.cat_a_time##i.libcon, cl(id)
testparm i.cat_a_time#i.libcon

**H5(P) The positive effect of policy descriptions that mention work or self-sufficiency (as opposed to descriptions that do not mention these concepts) will be greater for conservatives than for liberals.
*forced choice (dropping least attentive respondents)
reg program_choice i.workself##i.libcon eitc_tanf if screener_2plus==1, cl(id)
testparm i.workself#i.libcon

*forced choice (all respondents)
reg program_choice i.workself##i.libcon eitc_tanf, cl(id)
testparm i.workself#i.libcon

*program support (dropping least attentive respondents)
reg program_support i.workself##i.libcon eitc_tanf if screener_2plus==1, cl(id)
testparm i.workself#i.libcon

*program support (all respondents)
reg program_support i.workself##i.libcon eitc_tanf, cl(id)
testparm i.workself#i.libcon

*********************************************************************************
//Appendix
//Appendix B. Descriptive Statistics of Survey Sample
**table B.2.
codebook pid_7 age_ordinal white educ_new female income ideology if expand == 1
estpost summarize pid_7 age_ordinal white educ_new female income ideology if expand == 1

//Part one. Estimate AMCEs with ideological subgroups
**forced choice
*table G.1. (all respondents)
conjoint program_choice cat_a_desc cat_a_prob1 cat_a_prob2 cat_a_funding cat_a_cost cat_a_number cat_a_time, est(amce) id(id) constraint(cat_a_desc#cat_a_prob1#cat_a_prob2) subgroup(ideo3)

*table G.2. (dropping least attentive respondents)
conjoint program_choice cat_a_desc cat_a_prob1 cat_a_prob2 cat_a_funding cat_a_cost cat_a_number cat_a_time if screener_2plus==1, est(amce) id(id) constraint(cat_a_desc#cat_a_prob1#cat_a_prob2) subgroup(ideo3) 
matrix liberal_choice_2plus = e(results_Liberal)
matrix moderate_choice_2plus = e(results_Moderate)
matrix conservative_choice_2plus = e(results_Conservative)

**program support
*table G.3. (all respondents)
conjoint program_support cat_a_desc cat_a_prob1 cat_a_prob2 cat_a_funding cat_a_cost cat_a_number cat_a_time, est(amce) id(id) constraint(cat_a_desc#cat_a_prob1#cat_a_prob2) subgroup(ideo3)
matrix liberal_support = e(results_Liberal)
matrix moderate_support = e(results_Moderate)
matrix conservative_support = e(results_Conservative)

*table G.4. (dropping least attentive respondents)
conjoint program_support cat_a_desc cat_a_prob1 cat_a_prob2 cat_a_funding cat_a_cost cat_a_number cat_a_time if screener_2plus==1, est(amce) id(id) constraint(cat_a_desc#cat_a_prob1#cat_a_prob2) subgroup(ideo3)
matrix liberal_support_2plus = e(results_Liberal)
matrix moderate_support_2plus = e(results_Moderate)
matrix conservative_support_2plus = e(results_Conservative)

//Part two. AMCE by ideology (with moderates) figures
**generating forced choice AMCE by ideology (with moderates) figures
*figure G.1.
coefplot  matrix(liberal_choice[,1]), bylabel(Liberal) || ///
matrix(moderate_choice[,1]), bylabel(Moderate) || ///
matrix(conservative_choice[,1]), bylabel(Conservative) ||, ci(( 5 6)) ///
keep(*:) xline(0, lpattern(-) lcolor(black)) xlabel(-.1(.1).1) xtick(-.15(.05).15) coeflabels($labelreplace, labsize(vsmall)) eqlabels( "{bf:Policy Description}" "{bf:Policy Problem 1}" "{bf:Policy Problem 2}" "{bf:Funding Provided by}" "{bf:Total Cost per Year}" "{bf:Participant Population}" "{bf:Time Limit}", asheadings) byopts(graphregion(col(white)) cols(3)) subtitle(, fcolor (gs15)) scale(0.7) xtitle({bf:Estimated AMCEs (forced choice)})
gr export Figures/choice_ideo_amce.png, as(png) replace

*figure G.2.
coefplot  matrix(liberal_choice_2plus[,1]), bylabel(Liberal) || ///
matrix(moderate_choice_2plus[,1]), bylabel(Moderate) || ///
matrix(conservative_choice_2plus[,1]), bylabel(Conservative) ||, ci(( 5 6)) ///
keep(*:) xline(0, lpattern(-) lcolor(black)) xlabel(-.1(.1).1) xtick(-.15(.05).15) coeflabels($labelreplace, labsize(vsmall)) eqlabels( "{bf:Policy Description}" "{bf:Policy Problem 1}" "{bf:Policy Problem 2}" "{bf:Funding Provided by}" "{bf:Total Cost per Year}" "{bf:Participant Population}" "{bf:Time Limit}", asheadings) byopts(graphregion(col(white)) cols(3)) subtitle(, fcolor (gs15)) scale(0.7) xtitle({bf:Estimated AMCEs (forced choice)})
gr_edit .b2title.style.editstyle size(small) editcopy
gr_edit .b2title.text.Arrpush Excludes least attentive respondents
gr export Figures/choice_ideo_amce_2plus.png, as(png) replace

**generating program support AMCE by ideology (with moderates) figure
*figure G.3.
coefplot  matrix(liberal_support[,1]), bylabel(Liberal) || ///
matrix(moderate_support[,1]), bylabel(Moderate) || ///
matrix(conservative_support[,1]), bylabel(Conservative) ||, ci(( 5 6)) ///
keep(*:) xline(0, lpattern(-) lcolor(black)) xlabel(-.4(.2).4) coeflabels($labelreplace, labsize(vsmall)) eqlabels( "{bf:Policy Description}" "{bf:Policy Problem 1}" "{bf:Policy Problem 2}" "{bf:Funding Provided by}" "{bf:Total Cost per Year}" "{bf:Participant Population}" "{bf:Time Limit}", asheadings) byopts(graphregion(col(white)) cols(3)) subtitle(, fcolor (gs15)) scale(0.7) xtitle({bf:Estimated AMCEs (program support)})
gr export Figures/support_ideo_amce.png, as(png) replace

*figure G.4.
coefplot  matrix(liberal_support_2plus[,1]), bylabel(Liberal) || ///
matrix(moderate_support_2plus[,1]), bylabel(Moderate) || ///
matrix(conservative_support_2plus[,1]), bylabel(Conservative) ||, ci(( 5 6)) ///
keep(*:) xline(0, lpattern(-) lcolor(black)) xlabel(-.4(.2).4) coeflabels($labelreplace, labsize(vsmall)) eqlabels( "{bf:Policy Description}" "{bf:Policy Problem 1}" "{bf:Policy Problem 2}" "{bf:Funding Provided by}" "{bf:Total Cost per Year}" "{bf:Participant Population}" "{bf:Time Limit}", asheadings) byopts(graphregion(col(white)) cols(3)) subtitle(, fcolor (gs15)) scale(0.7) xtitle({bf:Estimated AMCEs (program support)}) 
gr_edit .b2title.style.editstyle size(small) editcopy
gr_edit .b2title.text.Arrpush Excludes least attentive respondents
gr export Figures/support_ideo_amce_2plus.png, as(png) replace

//Part three. Estimate marginal means per Leeper and Barnfield 2020
**forced choice
*table G.5. (all respondents)
conjoint program_choice cat_a_desc cat_a_prob1 cat_a_prob2 cat_a_funding cat_a_cost cat_a_number cat_a_time, est(mm) id(id) subgroup(ideo3)
matrix liberal_choice_mean = e(results_Liberal)
matrix moderate_choice_mean = e(results_Moderate)
matrix conservative_choice_mean = e(results_Conservative)

**program support
*table G.6. (all respondents)
conjoint program_support cat_a_desc cat_a_prob1 cat_a_prob2 cat_a_funding cat_a_cost cat_a_number cat_a_time, est(mm) id(id) subgroup(ideo3)
matrix liberal_support_mean = e(results_Liberal)
matrix moderate_support_mean = e(results_Moderate)
matrix conservative_support_mean = e(results_Conservative)


log close
exit
